<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>检索图像的嵌入式缩略图</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.exif-tagname.html">« exif_tagname</a></li>
      <li style="float: right;"><a href="function.read-exif-data.html">read_exif_data »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.exif.html">Exif 函数</a></li>
    <li>检索图像的嵌入式缩略图</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.exif-thumbnail" class="refentry">
  <div class="refnamediv">
   <h1 class="refname">exif_thumbnail</h1>
   <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">exif_thumbnail</span> &mdash; <span class="dc-title">检索图像的嵌入式缩略图</span></p>

  </div>
 <div class="refsect1 description" id="refsect1-function.exif-thumbnail-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>exif_thumbnail</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type">resource</span>|<span class="type">string</span></span> <code class="parameter">$file</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$width</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$height</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$image_type</code><span class="initializer"> = <strong><code>null</code></strong></span></span><br>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

   <p class="para rdfs-comment">
    <span class="function"><strong>exif_thumbnail()</strong></span> 读取图像的嵌入式缩略图。
</p>
  <p class="para">
   如果想通过该函数发送缩略图，应该使用 <span class="function"><a href="function.header.html" class="function">header()</a></span> 函数发送 mimetype 信息。
   </p>
  <p class="para">
   <span class="function"><strong>exif_thumbnail()</strong></span> 不能创建图像但能确定它的尺寸。在这种情况下，返回值是
   <strong><code>false</code></strong>，但会设置 <code class="parameter">width</code> 和 <code class="parameter">height</code>。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.exif-thumbnail-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">file</code></dt>

     <dd>

      <p class="para">
       图像文件的路径。可以是文件路径也可以是流 <span class="type">resource</span>。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">width</code></dt>

     <dd>

      <p class="para">
       返回缩略图的宽度。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">height</code></dt>

     <dd>

      <p class="para">
       返回缩略图的高度。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">image_type</code></dt>

     <dd>

      <p class="para">
       返回缩略图的图像类型。不是 <abbr title="Tagged Image File Format">TIFF</abbr> 就是 <abbr title="Joint Photographic Experts Group">JPEG</abbr>。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.exif-thumbnail-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回嵌入式缩略图，如果图像不包含缩略图则返回 <strong><code>false</code></strong>。
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.exif-thumbnail-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.2.0</td>
       <td>
        <code class="parameter">file</code> 参数现在支持本地文件和流资源。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.exif-thumbnail-examples">
  <h3 class="title">范例</h3>
  <p class="para">
    <div class="example" id="example-2607">
     <p><strong>示例 #1 <span class="function"><strong>exif_thumbnail()</strong></span> 示例</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$image&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">exif_thumbnail</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/to/image.jpg'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$image</span><span style="color: #007700">!==</span><span style="color: #0000BB">false</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;'&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">image_type_to_mime_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$type</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$image</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;没有可用的缩略图，这里处理错误<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'No&nbsp;thumbnail&nbsp;available'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.exif-thumbnail-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    如果传递流到此函数的 <code class="parameter">file</code>，然后流必须是可寻找的。请注意，此函数返回后，文件指针位置不会改变。
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.exif-thumbnail-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.exif-read-data.html" class="function" rel="rdfs-seeAlso">exif_read_data()</a> - 从一个图片文件中读取 EXIF 头信息</span></li>
    <li class="member"><span class="function"><a href="function.image-type-to-mime-type.html" class="function" rel="rdfs-seeAlso">image_type_to_mime_type()</a> - 取得 getimagesize、exif_read_data、exif_thumbnail、exif_imagetype 所返回的图像类型的 MIME 类型</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>